import store from '@/store';
const OSS = require('ali-oss');

export default async function generateOSS() {
  // 获取临时密钥
  await store.dispatch('sts/getSTS_miva');
  const credentials = store.getters.stsCache; // 获取临时密钥
  // 创建实例
  const client = new OSS({
    endpoint: 'oss-cn-beijing.aliyuncs.com',
    accessKeyId: credentials.AccessKeyId,
    accessKeySecret: credentials.AccessKeySecret,
    stsToken: credentials.SecurityToken,
    bucket: 'miva-work-resource',
    secure: true
  });
  return client;
}
